<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('商户对应通道费率列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            支付类型：<select name="payType" th:with="type=${@dict.getType('sys_channel_type')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                        </li>
                        <li>
                            用户状态：<select name="useStatus" th:with="type=${@dict.getType('sys_normal_disable')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                        </li>
                        <li>
                            支付商：<select name="payerId">
                            <option value=""></option>
                            <option th:each="user1:${users}" th:value="${user1.userId}" th:text="${user1.userName}"></option>
                        </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa btn-success"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa btn-success"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="settingStatus('0')" shiro:hasPermission="channel:businessRate:add">
                <i class="fa fa-plus"></i> 批量启用
            </a>
            <a class="btn btn-success" onclick="settingStatus('1')" shiro:hasPermission="channel:businessRate:add">
                <i class="fa fa-plus"></i> 批量停用
            </a>
            <a class="btn btn-success" onclick="closeItem()">
                <i class="fa fa-download">关闭</i>
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var channelId = '[[${channelId}]]'
    var editFlag = [[${@permission.hasPermi('channel:businessRate:edit')}]];
    var removeFlag = [[${@permission.hasPermi('channel:businessRate:remove')}]];
    var prefix = ctx + "channel/businessRate";
    var datastatus = [[${@dict.getType('sys_normal_disable')}]];
    $(function () {
        var options = {
            url: prefix + "/list/channel/" + channelId,
            createUrl: prefix + "/add/" + channelId,
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export/channel" + channelId,
            modalName: "商户对应通道费率",
            showExport: true,
            columns: [{
                checkbox: true
            },
                {
                    field: 'rateId',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'businessName',
                    title: '商户名称',
                    sortable: true
                },
                {
                    field: 'payTypeLabel',
                    title: '支付类型',
                    sortable: true
                },
                {
                    field: 'payRate',
                    title: '商户费率',
                    sortable: true
                },
                {
                    field: 'channelUserName',
                    title: '指派码商',
                },
                {
                    field: 'payerUserName',
                    title: '指派支付商',
                },
                {
                    field: 'payerPayTypeLabel',
                    title: '支付商支付类型',
                },
                {
                    field: 'useStatus',
                    title: '使用状态',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datastatus, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.rateId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.rateId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function settingStatus(useStatus) {
        var url = prefix + '/edit/channel';

        var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId);
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.confirm("确认要操作这些数据吗?", function() {
            var data = { "ids": rows.join(), useStatus: useStatus};
            $.operate.submit(url, "post", "json", data);
        });
    }
</script>
</body>
</html>